<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui" xmlns:c="http://xmlns.jcp.org/jsp/jstl/core">

    <f:view contentType="text/html">
        <h:head>
            <f:facet name="first">
                <meta content='text/html; charset=UTF-8' http-equiv="Content-Type"/>
                <title>Autoviação Pasa</title>
            </f:facet>
        </h:head>

        <h:body>
            <h:form>
                <p:layout fullPage="true">

                    <p:layoutUnit position="north" size="230" resizable="false" closable="false" collapsible="true">
                        <h:graphicImage url="/banner.jpg" width="700" height="200"/>
                        <h:outputText value = " Logado como cliente: #{managedBeanClientes.cliente.nome} " 
                                      rendered="#{managedBeanClientes.login}"/>
                        <h:commandButton value = "Carrinho: #{managedBeanVenda.listaCarrinho.size()} " action="venda" 
                                         rendered="#{managedBeanClientes.login}"/>
                        <h:commandButton value = "Minha conta" action="dadospessoais-cliente" 
                                         rendered="#{managedBeanClientes.login}"/>
                        <h:commandButton value = "Sair" action="#{managedBeanClientes.logout()}" 
                                         rendered="#{managedBeanClientes.login}"/>    

                        <h:outputText value = " Logado como empresa: #{managedBeanEmpresa.empresa.nome} "
                                      rendered="#{managedBeanEmpresa.login}"/> 
                        <h:commandButton value = "Minha conta" action="dadosjuridicos-empresa" 
                                         rendered="#{managedBeanEmpresa.login}"/>
                        <h:commandButton value = "Sair" action="#{managedBeanEmpresa.logout()}" 
                                         rendered="#{managedBeanEmpresa.login}"/>
                    </p:layoutUnit>

                    <p:layoutUnit position="west" size="259" collapsible="true">
                        <p:menu>
                            <p:submenu label="Login" rendered="#{!managedBeanClientes.login and !managedBeanEmpresa.login}">
                                <p:menuitem value="Cliente" outcome="login-cliente" />
                                <p:menuitem value="Empresa" outcome="login-empresa"/>
                            </p:submenu>
                            <p:submenu label="Cadastre-se" rendered="#{!managedBeanClientes.login and !managedBeanEmpresa.login}">
                                <p:menuitem value="Cliente" outcome="cadastro-cliente" />
                                <p:menuitem value="Empresa" outcome="cadastro-empresa"/>
                            </p:submenu>
                            <p:submenu label="Minha Empresa" rendered="#{managedBeanEmpresa.login}">
                                <p:menuitem value="Cadastrar Ônibus" outcome="cadastro-onibus"/>
                                <p:menuitem value="Cadastrar Viagem" outcome="cadastro-viagem" />
                            </p:submenu>
                            <p:submenu label="Menu">
                                <p:menuitem value="Inicio" outcome="index"/>
                                <p:menuitem value="Quem Somos" outcome="quemsomos" />
                                <p:menuitem value="Empresas Filiadas" outcome="lista-empresa"/>
                                <p:menuitem value="Compra de Passagens" outcome="consulta-onibus" rendered="#{!managedBeanEmpresa.login}"/>
                                <p:menuitem value="Minhas Compras" outcome="index" rendered="#{managedBeanClientes.login}"/>
                            </p:submenu>
                        </p:menu>
                    </p:layoutUnit>
                    <p:layoutUnit position="center">
                        <c:if test="#{managedBeanClientes.login}">
                            <p:panel header="Minhas compras">
                                <p:panelGrid columns="2">
                                    <p:dataTable  value = "#{managedBeanVenda.listarVendasCliente(managedBeanClientes.cliente)}" var ="v">
                                        <p:column headerText ="Origem">
                                            <h:outputText value ="#{v.id_viagem.origem}"/>
                                        </p:column>
                                        <p:column headerText="Destino">
                                            <h:outputText value ="#{v.id_viagem.destino}"/>
                                        </p:column>
                                        <p:column headerText ="Empresa">
                                            <h:outputText value ="#{v.id_viagem.empresa.nome}"/>
                                        </p:column>
                                        <p:column headerText ="Data">
                                            <h:outputText value ="#{managedBeanViagem.formatarData(v.data)}"/>
                                        </p:column>
                                        <p:column headerText ="Valor">
                                            <h:outputText value ="R$ #{v.preco}"/>
                                        </p:column>
                                        <p:column headerText ="Poltrona">
                                            <h:outputText value ="#{v.id_poltrona.numero_poltrona}"/>
                                        </p:column>
                                    </p:dataTable>
                                </p:panelGrid>
                            </p:panel>
                            <p:messages showDetail="true"/>
                        </c:if>
                    </p:layoutUnit>
                </p:layout>
            </h:form>
        </h:body>
    </f:view>
</html>

